



def get_block(v, n):
    result = []
    for i in range(len(v)-n):
        result.append(float(sum(v[i:i+n])) / n)
    return result

def average(v):
    n = len(v)
    ave = float(sum(v)) / n
    err = 0.0
    for i in v:
        err += (i-ave)*(i-ave)
    err = sqrt(err / (n-1))
    return (ave, err,)
        

def block_average(v, n):
    blocks = get_block(v, n)
    return average(blocks)
    

data = [1.2, 2.4, 4.5,]

print block_average(data, 20)